package com.itboye.textileexpes.adapter;

import java.util.List;

import com.itboye.textileexpes.beans.CityBeans;
import com.itboye.textileexpres.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class ListCityAdapter extends BaseAdapter{
	private LayoutInflater inflater;
	private List<CityBeans> list;
	
	public  ListCityAdapter(Context inflater,List<CityBeans> list){
		this.list=list;
		this.inflater=LayoutInflater.from(inflater);
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHouder houder;
		if(convertView==null){
			houder=new ViewHouder();
			convertView=inflater.inflate(R.layout.item_city, null);
			houder.name=(TextView) convertView.findViewById(R.id.name);
			convertView.setTag(houder);
		}else{
			houder=(ViewHouder) convertView.getTag();
		}
		houder.name.setText(list.get(position).getCountry_name());
		return convertView;
	}
	class ViewHouder{
		
		
		TextView name;
	}

}
